<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */
get_header();
if($post->post_parent) $parent_title = get_the_title($post->post_parent);
else $parent_title = get_the_title();
$parent_title = join("-", explode(" ", $parent_title));
?>

		<div id="primary" class="page-<?php echo strtolower($parent_title);?>">
			<div id="content" role="main">
				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

				<?php while ( have_posts() ) : the_post(); ?>
<?php
					
					if (strtoupper($parent_title) == 'FORNECEDORES') {
						
?>
						<div id="marca-single">
							<div class="fr"><?php get_template_part( 'filtro-origem'); ?></div>
							<h1 class="entry-title fl"><?php the_title(); ?></h1>
							<br class="clear">
<?							$array = get_post_custom_values('imagem'); 
							$imagem = $array[0];
							$array = get_post_custom_values('descricao'); 
							$descricao = $array[0];
?>
							<img src="<?=get_bloginfo('wpurl');?>/wp-content/files_mf/<?=$imagem;?>" />
							<?php echo $descricao; ?>
						</div>
		<?php
		$args = array (
			'order'                  => 'ASC',
			'orderby'                => 'title',
			'nopaging'     			 => true,
			'meta_query'             => array(
				array(
					'key'       => 'fabricante',
					'value'     => get_the_id(),
					'compare'   => '=',
				),
			),
		);

		// The Query
		$query = new WP_Query( $args );

		// The Loop
		if ( $query->have_posts() ) { ?>
			<div class="block100 mTopBtm"><div id="produtosdamarca">PRODUTOS DA MARCA</div></div>
			<ul class="bxslider">
				<?php
					while ( $query->have_posts() ) {
						$query->the_post();
						$tamanho="h=210&w=189&zc=1&q=80";
					?>
						<li><a href="<?php the_permalink();?>"><?php echo get_image('imagens',1,1,1,NULL,$tamanho); ?></a></li>
					<?php
					}
				?>
			</ul>
		<?php
		}
		wp_reset_postdata();
		/*
		?>
		<ul class="bxslider">
			<li><img src="<?php bloginfo('template_url') ?>/images/produtos_temp/azeites1.jpg" /></li>
			<li><img src="<?php bloginfo('template_url') ?>/images/produtos_temp/azeites2.jpg" /></li>
			<li><img src="<?php bloginfo('template_url') ?>/images/produtos_temp/azeites3.jpg" /></li>
			<li><img src="<?php bloginfo('template_url') ?>/images/produtos_temp/azeites4.jpg" /></li>
			<li><img src="<?php bloginfo('template_url') ?>/images/produtos_temp/azeites5.jpg" /></li>
			<li><img src="<?php bloginfo('template_url') ?>/images/produtos_temp/azeites1.jpg" /></li>
		</ul>
		<?php
		*/
		?>
		<div class="block100 mTopBtm">
			<?php
			$args = array(
				'authors'      => '',
				'child_of'     => $post->ID,
				'date_format'  => get_option('date_format'),
				'depth'        => 0,
				'echo'         => 1,
				'exclude'      => '',
				'include'      => '',
				'link_after'   => '',
				'link_before'  => '',
				'post_type'    => 'page',
				'post_status'  => 'publish',
				'show_date'    => '',
				'sort_column'  => 'menu_order, post_title',
				'title_li'     => __('Pages'), 
				'walker'       => '',
				'order'        => 'ASC',
				'orderby'      => 'title',
				'nopaging'     => true
			);
			$query = new WP_Query( $args );
			if ( $query->have_posts() ) {
			?>
			<select name="outras_marcas" id="outras_marcas" class="fl" onchange="document.location.href=this.options[this.selectedIndex].value;">
				<option value="">Selecione outra marca</option>
			<?php
				while ( $query->have_posts() ) {
					$query->the_post();
				?>
				<option value="<?php the_permalink(); ?>"><?php the_title(); ?></option>
				<?php
				}
			?>
			</select>			
			<?php
			}
			wp_reset_postdata();
			?>
			<!-- 	<option value="">Selecione outra marca</option>
			<option value="">Estación</option>
			<option value="">Caldirola</option>
			<option value="">San Ignacio</option>
			<option value="">Di Marlino</option>
			<option value="">Fragata</option> -->
			
		</div>
<?php
				}else{ ?>
							<header class="entry-header">
								<h1 class="entry-title"><?php the_title(); ?></h1>
							</header><!-- .entry-header -->

							<div class="entry-content">
								<?php the_content(); ?>
								<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
							</div><!-- .entry-content -->
							<footer class="entry-meta">
								<?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?>
							</footer><!-- .entry-meta -->
<?php 				} ?>
					
				<?php endwhile; // end of the loop. ?>
				</article><!-- #post-<?php the_ID(); ?> -->
				<div class="clear"></div>
			</div><!-- #content -->
		</div><!-- #primary -->
<?php get_sidebar('page'); ?>
<?php get_footer(); ?>